﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ResXDSL_Sample
{
    /// <summary>
    /// Example of using ResX DSL.
    /// </summary>
    public partial class WhoAmI : Page
    {
        /// <summary>
        /// Ressources-Manager with Culture imported from app-settings
        /// </summary>
        private ResxManager resxManager = new ResxManager(Properties.Settings.Default.Culture);

        /// <summary>
        /// Constructor
        /// </summary>
        public WhoAmI()
        {
            InitializeComponent();
            
            // assign ressources to form controls
            AssignRessources();
        }

        /// <summary>
        /// Assign ressources from resx-manager object to form controls
        /// </summary>
        private void AssignRessources()
        {
            tbCaption.Text = resxManager.MainPage.AsString;
            tbFirstName.Text = resxManager.FirstName.AsString;
            tbLastName.Text = resxManager.LastName.AsString;
            btnWhoAmI.Content = resxManager.Question.AsString;
            btnWhoAmI.Width = resxManager.Question.AsInteger;
        }

        private void btnWhoAmI_Click(object sender, RoutedEventArgs e)
        {
            // compose "Who I am?"-Answer
            string answer = String.Format("{0} {1} {2}!", 
                resxManager.AnswerPrefix.AsString, 
                txtFirstName.Text, txtLastName.Text);

            MessageBox.Show(answer);
        }
    }
}
